<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>教师题目情况</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="<%=basePath%>layui/css/layui.css" media="all">
  
<script src="<%=basePath%>/js/jquery-3.2.1.min.js"></script>
</head>
<body>
<iframe style="width:100%;height:100%;display:none;" id="add_page" src="/bysjxksys/pages/admin/addStu.jsp" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"></iframe>
<iframe style="width:100%;height:100%;display:none;" id="edit_page" src="/bysjxksys/pages/admin/editStu.jsp" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"></iframe>

<form class="layui-form">
	<div class="layui-form-item" id="list_page" style="margin-top:30px;">
	    <div class="layui-inline">
		    <label class="layui-form-label">题目名称：</label>
		    <div class="layui-input-inline">
			    <input class="layui-input" type = "text" id="account">
			</div>
		</div>
	    <div class="layui-inline">
		    <label class="layui-form-label">教师姓名：</label>
		    <div class="layui-input-inline">
			    <input  class="layui-input" type = "text" id="username">
			</div>
		</div>
	    <div class="layui-inline" style="margin-right:10px;">
			<button type="button" class="layui-btn search_btn" data-type="reload">查询</button>
			<!-- <button type="button" class="layui-btn" onclick="add();">添加</button> -->
		</div>
 	 </div>
 	 <div style="margin-left:10px; margin-right:10px;">
		<table id="userlist" lay-filter="userlist"></table>
	 </div>
</form>

<script type="text/html" id="caozuo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">详情</a>
</script>

</body>


<script src="<%=basePath%>/js/vue.min.js"></script>
<script src="<%=basePath%>/layui/layui.js" charset="utf-8"></script>
<script>
layui.use('table', function() {
	var table = layui.table;
	
	

	table.render({
		elem : '#userlist',
	    height:450,
		// width: 800,
		page: true,
		limit: 10,
		url : '/bysjxksys/admin/subject_list',
		where:{
			account:  $('#account').val(),
			username: $('#username').val()
		},
		response: {
			statusName: 'code'   //规定数据状态的字段名称，默认：code
			,statusCode: 0       //规定成功的状态码，默认：0
			,msgName:   'msg'    //规定状态信息的字段名称，默认：msg
			,countName: 'count'  //规定数据总数的字段名称，默认：count
			,dataName:  'data'   //规定数据列表的字段名称，默认：data
		},
		cols: [[ //标题栏
			{field: '', title: '序号', width:40, type:'numbers'}
		    ,{field: 'tname', title: '拟题教师', align:'center',templet: '<div>{{d.teacher ? d.teacher.tname: ""}}</div>'}
		    ,{field: 'sbjName', title: '题目名称', align:'center'}
		    ,{field: 'sbjContent', title: '题目简介', align:'center'}
		   ,{field: 'sbjType', title: '类别', align:'center'}
		   ,{field: 'sbjMajor', title: '适合专业', align:'center'}
		   ,{field: 'fbTime', title: '发布时间', align:'center',templet : "<div>{{layui.util.toDateString(d.sbj_start, 'yyyy年-MM月-dd日')}}</div>"}
		   ,{title : '操作', toolbar: '#caozuo', align: 'center'}
		]],
        id : "userlistTable"
    });

    table.on('tool(userlist)', function(obj){
    	var data = obj.data;
    	if(obj.event === 'edit'){
    		localStorage.setItem('stuId',data.stuId);
    		localStorage.setItem('sno',data.sno);
    		localStorage.setItem('sname',data.sname);
    		localStorage.setItem('sex',data.sex);
    		localStorage.setItem('sPassword',data.sPassword);
    		localStorage.setItem('sDepartment',data.sDepartment);
    		localStorage.setItem('sClass',data.sClass);
    		localStorage.setItem('email',data.email);
    		localStorage.setItem('sPhone',data.sPhone);
    		
    		layer.open({
                type: 2,
                title : '教师题目详情信息',
                //skin: 'layui-layer-rim', //加上边框
                area: ['800px', '600px'], //宽高
                content:'/bysjxksys/pages/admin/editStu.jsp',
                btn:['确定','取消'],
                yes:function(index,layero){
                    var formSubmit = layer.getChildFrame('form',index);
                    var submited = formSubmit.find('button')[0];
                    submited.click();
                    location.reload();
                }
            });
    
    	}
   	});

    $(".search_btn").on("click",function(){
		table.reload("userlistTable",{
			page: {
				curr: 1 //重新从第 1 页开始
			},
			where:{
				account:  $('#account').val(),
				username: $('#username').val()
			}
		});
	});
}); 

</script>
</html>
</html>